package com.potenza.training.dictionary.server.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.potenza.training.dictionary.dao.HopeMaxSalaryDao;
import com.potenza.training.dictionary.entity.HopeMaxSalary;
import com.potenza.training.dictionary.server.HopeMaxSalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("hopeMaxSalaryServiceImpl")
public class HopeMaxSalaryServiceImpl extends ServiceImpl<HopeMaxSalaryDao, HopeMaxSalary> implements HopeMaxSalaryService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public List<HopeMaxSalary> findAll() {
        Object maxSalary = redisTemplate.opsForValue().get("maxSalary");
        if (maxSalary==null){
            List<HopeMaxSalary> list = this.list();
            redisTemplate.opsForValue().set("maxSalary", list);
            return list;
        }
        return (List<HopeMaxSalary>)maxSalary;
    }
}